package cn.ffcs.uec.outStaffDataModificationApply.action;


import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.ForwardEvent;

import cn.ffcs.raptornuke.plugin.common.zk.ctrl.BasePortletComposer;
import cn.ffcs.raptornuke.portal.theme.ThemeDisplay;
import cn.ffcs.uec.outStaffDataModificationApply.action.bean.UecOutDocEduApprovalMainBean;
import cn.ffcs.uec.recordsApproval.constant.ApprovalConstants;
import cn.ffcs.uec.recordsApproval.vo.TaskVo;
import cn.ffcs.uom.common.util.UomZkUtil;

/**
 * 外包人员教育经历审批
 *
 */
@Controller
@Scope("prototype")
public class UecOutDocEduApprovalMainComposer extends BasePortletComposer {
	private static final long serialVersionUID = 2792881365660141180L;

	private UecOutDocEduApprovalMainBean bean = new UecOutDocEduApprovalMainBean();
	
	private TaskVo task;
	
	@Override
	public String getPortletId() {
		return super.getPortletId();
	}

	@Override
	public ThemeDisplay getThemeDisplay() {
		return super.getThemeDisplay();
	}
	
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		Components.wireVariables(comp, bean);
		UomZkUtil.autoFitHeight(comp);// 使用<borderlayout>时，需要加上这句进行初始化，不然从仓库调出的页面，不能显示
		
		this.bean.getRecordsHistoricFlowListBoxExt().addForward(ApprovalConstants.ON_SELECTED_TASK, 
				comp, ApprovalConstants.ON_SELECTED_TASK_RESPONSE);
		
		this.bean.getRecordsApprovalListBoxExt().getBean().getCategoryLabel().setVisible(false);
		this.bean.getRecordsApprovalListBoxExt().getBean().getCategoryId().setVisible(false);
	}
	
	/**
	 * 获取选中的待显示流程流转信息的待办任务
	 * @param event
	 */
	public void onSelectTaskResponse(ForwardEvent event) {
		task = (TaskVo) event.getOrigin().getData();
		if(null != task) {
			Events.postEvent(ApprovalConstants.ON_SELECTED_OUTSTAFF_ENTRY_HISTORIC_FLOW, 
					this.bean.getRecordsHistoricFlowListBoxExt(), task);

		}
	}

	
}
